package com.yyfax.pay.depository.vo;

import com.yyfax.framework.model.BasePO;
import com.yyfax.pay.common.enums.FuiouDepositStateEnum;
import com.yyfax.pay.common.exception.PayExceptionCode;
import com.yyfax.pay.depository.domain.FuiouCharge;

/**
 * 富友快捷充值快照类
 * 
 * @author buyi
 * @date 2017-08-30 09:56:00
 * @since v2.0.0
 */
@SuppressWarnings("serial")
public class FuiouChargeVO extends BasePO {
	private FuiouCharge po;

	/**
	 * 创建一个实例
	 * 
	 * @author buyi
	 * @date 2017-09-28 17:10:53
	 * @since v2.0.0
	 * @param po
	 * @return
	 */
	public static FuiouChargeVO newInstantce(FuiouCharge po) {
		if (po == null) {
			throw PayExceptionCode.ERROR_ILL_PARAMETER.expMsg("请求参数po不能为空");
		}

		return new FuiouChargeVO().setPo(po);
	}

	private FuiouChargeVO() {
		super();
	}

	public FuiouCharge getPo() {
		return po;
	}

	public FuiouChargeVO setPo(FuiouCharge po) {
		this.po = po;
		return this;
	}

	/**
	 * 判断订单是否已经出结果
	 * 
	 * @author buyi
	 * @date 2017-08-30 10:00:35
	 * @since v2.0.0
	 * @return false-未出结果，true-已经出结果
	 */
	public boolean isResult() {
		// 如果订单状态成功、失败，则已经出结果
		if (FuiouDepositStateEnum.FAIL.isValue(po.getState()) || FuiouDepositStateEnum.SUCCESS.isValue(po.getState())) {
			return true;
		}

		return false;
	}

	/**
	 * 判断订单是否查询
	 * 
	 * @author buyi
	 * @date 2017-09-25 15:21:58
	 * @since v2.0.0
	 * @return
	 */
	public boolean isQuery() {
		if (FuiouDepositStateEnum.DEALING.isValue(po.getState()) || FuiouDepositStateEnum.ACCEPTED.isValue(po.getState())
				|| FuiouDepositStateEnum.TIMEOUT.isValue(po.getState())) {
			// 如果订单状态是处理中,已受理，或者超时，则可以支持查询
			return true;
		}

		return false;
	}

}
